//导入Vue模块
import Vue from 'vue'


//导入路由模块
import VueRouter from 'vue-router'
//把路由模块安装在vue框架中，这样模块就是一个全局模块，在任何地方都可以使用路由模块，像使用Vue下的方法，属性那样使用路由模块的相关功能，属性
Vue.use(VueRouter)


import VueResource from 'vue-resource'
Vue.use(VueResource)


import VueBus from 'vue-bus'
Vue.use(VueBus)


//导入四个路由页面组件
import Home from '../components/home/home'
import Nine from '../components/nine/nine'
import List from '../components/list/list'
import Mine from '../components/mine/mine'


// home页面的相关引入
import HomeGirl from '../components/home/homeGirl'
import HomeBoy from '../components/home/homeBoy'



//导入二级路由
import NineBoy from '../components/nine/nine_boy'
import NineGirl from '../components/nine/nine_girl'

import ListBoy from '../components/list/list_boy'
import ListGirl from '../components/list/list_girl'


//导入详情页二级路由
import Xiang from '../components/nine/xiang'
import Refer from '../components/nine/refer'
import Attr from '../components/nine/attr'


// 首页点击跳转的分类页路由引入
import Sort from '../components/home/sort'

//我的页面的各种路由
import Info from '../components/mine/info'
import UserMsg from '../components/mine/logined'
import Login from '../components/mine/login'
import Collect from '../components/mine/collect'
import Order from '../components/mine/order'
import Coupon from '../components/mine/coupon'


// 公共搜索页引入
import Search from '../components/common/search'
// 购物车页引入
import Cart from '../components/common/cart'
// 去支付和立即购买跳转页面
import Pay from '../components/common/pay'


//分类页面导航点击跳转
import Category from '../components/list/category'
//分类页面产品点击详情
import ListDetail from '../components/common/list_detail'


//客服跳转路由
import Serv from '../components/nine/serv'
//收货地址跳转
import Address from '../components/mine/address'
//添加收货地址
import Address_add from '../components/mine/address_add'

import AllOrder from '../components/mine/all_order'
import NoPay from '../components/mine/no_pay'
import NoSend from '../components/mine/no_send'
import NoReceive from '../components/mine/no-receive'
import NoComment from '../components/mine/no_comment'
import ShopCoupou from '../components/mine/shop_coupou'
import ChuCoupou from '../components/mine/chu_coupou'
import Refund from '../components/mine/refund'


let routes = [
	//利用路由传值，在注册路由条目时，使用冒号拼接进一个变量名的形式注册路由
	{path:'', redirect: '/home'},
	{path:'/home', component: Home, children: [
		{path: '', redirect: 'homeGirl'},
		{path: 'homeGirl', component: HomeGirl},
		{path: 'homeBoy', component: HomeBoy},
		{path: 'search', component: Search}
	]},
	{path: '/sort/:id', component: Sort},
	{path:'/nine', component:Nine, children:[
		{path:'', redirect:'nineGirl'},
		{path:'ninegirl', component:NineGirl},
		{path:'nineboy', component:NineBoy},
		{path: 'search', component: Search}
	]},
	{path: '/serv', component: Serv},
	{path:'/category/:id', component:Category},
	{path:'/details/:id', component:ListDetail},
	{path:'/list', component:List, children:[
		{path:'', redirect:'listgirl'},
		{path:'listgirl', component:ListGirl},
		{path:'listboy', component:ListBoy}
	]},
    {path:'/login', component:Login},
	{path:'/mine', component:Mine},
	{path:'/address', component:Address},
	{path:'/address_add', component:Address_add},
	{path:'/address_add', component:Address_add},
    {path:'/info', component:Info},
    {path:'/coupon', component:Coupon, children:[
        {path:'chuCoupou', component:ChuCoupou},
        {path:'shopCoupou', component:ShopCoupou}
    ]},
    {path:'/order', component:Order, children:[
        {path:'allOrder', component:AllOrder},
        {path:'noPay', component:NoPay},
        {path:'noSend', component:NoSend},
        {path:'noReceive', component:NoReceive},
        {path:'noComment', component:NoComment}
    ]},
    {path:'/collect', component:Collect},
    {path:'/refund', component:Refund},
    {path:'/userMsg', component:UserMsg},
	{path: '/cart', component: Cart},
	{path: '/pay', component: Pay}
]



//创建一个路由实例
let router = new VueRouter({
	mode: 'history',
	routes
})

//导出router
export default router;



//修改根标签字体
(function (doc, win) {
		var docEl = doc.documentElement,
    	resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
    	recalc = function () {
        var clientWidth = docEl.clientWidth;
        if (!clientWidth) return;
        if(clientWidth>=640){
            docEl.style.fontSize = '100px';
        }else{
            docEl.style.fontSize = 24 * (clientWidth / 640) + 'px';
        }
    };

		if (!doc.addEventListener) return;
	win.addEventListener(resizeEvt, recalc, false);
	doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);
